package com.elink.enginerring.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.elink.enginerring.common.ErrorType;
import com.elink.enginerring.service.LabelService;
import com.elink.enginerring.util.JSONUtil;

@RestController
@RequestMapping(value="/api/tag")
@Api(value="标签接口")
public class LabelController {
	@Autowired
	private  LabelService labelService;
	
	/**
	 * 增加标签
	 * @param labels
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ApiOperation(value="增加标签",httpMethod="POST")
	public Map<String, Object> add(@ApiParam(value="标签集合,用,进行分割")
	@RequestParam("labels")String labels,HttpServletRequest request){
		@SuppressWarnings("unchecked")
		Map<String,Object> userInfo  = (Map<String, Object>) request.getAttribute("userInfo");
		String userId =  userInfo.get("userId").toString();
		return JSONUtil.getJSON(ErrorType.SUCCESS,labelService.add(labels,userId));
	}
}
